var elementKeyMap = {
	"supplierLv":elementKeyMap(requestData(path+"/supplier-lv")),
	"supplierClass":elementKeyMap(requestData(path+"/supplier-classification"))
}
var arrayKeyMap = {
	"supplierLv":ObjectConvertArray(elementKeyMap.supplierLv),
	"supplierClass":ObjectConvertArray(elementKeyMap.supplierClass),
}
$(function(){
   //创建渲染表格所需要的数据
   var data = {
		method: 'GET',
		url:path+'/procurement/supplier-archives',
		columns: [{
			field: 'checked',
			checkbox: true
		}, {
			field: 'supArchiId',
			title: '编号',
			visible: false
		}, {
			field: 'supArchiEnterpriseName',
			title: '公司名称',
			searchable: true
		}, {
			field: 'supArchiLinkMan',
			title: '联系人',
			searchable: true
		}, {
			field: 'supArchiSex',
			title: '性别'
		}, {
			field: 'supArchiBirthday',
			title: '生日'
		}, {
			field: 'supArchiLinkTel',
			title: '联系电话'
		}, {
			field: 'supArchiLinkPhone',
			title: '联系手机',
			searchable: true
		}, {
			field: 'supArchiEmail',
			title: '电子邮箱'
		}, {
			field: 'supArchiZipCode',
			title: '邮编'
		}, {
			field: 'supArchiFax',
			title: '传真'
		}, {
			field: 'supArchiQq',
			title: 'QQ',
			searchable: true
		}, {
			field: 'supArchiWechat',
			title: '微信',
			searchable: true
		}, {
			field: 'supArchiLinkAddress',
			title: '联系地址'
		}, {
			field: 'supArchiCustomerLv',
			title: '供应商级别',
			formatter: function (value, row, index) {
				return elementKeyMap.supplierLv[value].value;
            }
		}, {
			field: 'supArchiCustomerClass',
			title: '供应商分类',
			formatter: function (value, row, index) {
				return elementKeyMap.supplierClass[value].value;
            }
		}, {
			field: 'supArchiProduct',
			title: '产品范围'
		}, {
			field: 'supArchiRemark',
			title: '备注'
		}],	
		sortable: true,
        sortOrder: "asc",
        search: false
   }
   
   var param = [{
		text: "公司名称",
		name: "supArchiEnterpriseName",
		type: "text",
		verify: "enterpriseName"
	}, {
		text: "联系人",
		name: "supArchiLinkMan",
		type: "text",
		verify: "peopleName"
	}, {
		text: "联系地址",
		name: "supArchiLinkAddress",
		type: "text",
		verify: "cnw"
	}, {
		text: "产品范围",
		name: "supArchiProduct",
		type: "text",
		verify: "chineseStr"
	}, {
		text: "供应商级别",
		name: "supArchiCustomerLv",
		type: "select",
		verify: "",
		option: arrayKeyMap.supplierLv
	}, {
		text: "供应商分类",
		name: "supArchiCustomerClass",
		type: "select",
		verify: "",
		option: arrayKeyMap.supplierClass
	}];
   
   renderTable(cTable,data);
   createQueryPanel(param);
   form.render();
})

/**
* 删除选中的记录
*/
$("#remove_btn").click(function(){
	requestRemoveData("supArchiId","/procurement/supplier-archives");
})
   
/**
* 添加一条记录按钮
*/
$('#add_btn').click(function(){
   openOperateWindow({
	   title: "添加供应商",
	   url: "/admin/enterpriseManagement/procurementManagement/supplierArchives/supplier-archives-add.jsp"
   })
});
   
/**
* 修改一条记录按钮
*/
$('#modify_btn').on('click',function(){
	openOperateWindow({
		title: "修改供应商资料",
		isUpdate: true,
		url: "/admin/enterpriseManagement/procurementManagement/supplierArchives/supplier-archives-update.jsp"
	})
});
